package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.system.domain.vo.UserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SuperBirthdayMapper;
import com.ruoyi.system.domain.SuperBirthday;
import com.ruoyi.system.service.ISuperBirthdayService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 用户生日Service业务层处理
 * 
 * @author mzh
 * @date 2025-08-17
 */
@Service
public class SuperBirthdayServiceImpl implements ISuperBirthdayService 
{
    @Autowired
    private SuperBirthdayMapper superBirthdayMapper;

    /**
     * 查询用户生日
     * 
     * @param id 用户生日主键
     * @return 用户生日
     */
    @Override
    public SuperBirthday selectSuperBirthdayById(Long id)
    {
        return superBirthdayMapper.selectSuperBirthdayById(id);
    }

    /**
     * 查询用户生日列表
     * 
     * @param superBirthday 用户生日
     * @return 用户生日
     */
    @Override
    public List<SuperBirthday> selectSuperBirthdayList(SuperBirthday superBirthday)
    {
        return superBirthdayMapper.selectSuperBirthdayList(superBirthday);
    }

    /**
     * 新增用户生日
     * 
     * @param superBirthday 用户生日
     * @return 结果
     */
    @Override
    public int insertSuperBirthday(SuperBirthday superBirthday)
    {
        return superBirthdayMapper.insertSuperBirthday(superBirthday);
    }

    /**
     * 修改用户生日
     * 
     * @param superBirthday 用户生日
     * @return 结果
     */
    @Override
    public int updateSuperBirthday(SuperBirthday superBirthday)
    {
        return superBirthdayMapper.updateSuperBirthday(superBirthday);
    }

    /**
     * 批量删除用户生日
     * 
     * @param ids 需要删除的用户生日主键
     * @return 结果
     */
    @Override
    public int deleteSuperBirthdayByIds(Long[] ids)
    {
        return superBirthdayMapper.deleteSuperBirthdayByIds(ids);
    }

    /**
     * 删除用户生日信息
     * 
     * @param id 用户生日主键
     * @return 结果
     */
    @Override
    public int deleteSuperBirthdayById(Long id)
    {
        return superBirthdayMapper.deleteSuperBirthdayById(id);
    }

    @Override
    public SuperBirthday getBirthdayByUserId(Long userId) {
        return superBirthdayMapper.getBirthdayByUserId(userId);
    }

    @Override
    @Transactional
    public int updateUserInfo(UserVo user) {
        int i = superBirthdayMapper.updateUserInfo(user);

        SuperBirthday birthday = new SuperBirthday();
        birthday.setUserId(user.getUserId());
        birthday.setBirthday(user.getBirthday());
        i *= superBirthdayMapper.updateBirthdayUserId(birthday);

        return i;
    }
}
